package com.example.testmvp.model;

import android.os.Handler;
import android.text.TextUtils;

import com.example.testmvp.presener.OnLoginFinishedListener;

/**
 * Created by Administrator on 2017/5/23.
 */

public class LoginModelImpl implements LoginModelInterface {

    @Override
    public void login(final User user, final OnLoginFinishedListener listener) {
        final String userName = user.getUsername();
        final String pwd = user.getPassword();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                boolean error = false;
                if(TextUtils.isEmpty(userName)){
                    listener.onUsernameError();
                    error = true;
                }
                if(TextUtils.isEmpty(pwd)){
                    listener.onPasswordError();
                    error = true;
                }
                if(!error){
                    listener.onSuccess();
                }
            }
        },2000);
    }
}
